<template>
	<view class="backview">
		<lexiconNavVue title="全方位备赛套餐" />
		<view class="top-menu">
		</view>
		<scroll-view class="words-scroll" :style="{ height: scrollHeight + 'px'}" scroll-y
			:scroll-with-animation='true'>
			<view style="width: 100%; display: flex; align-items: center; flex-direction: column;">
				<view class="gameType-content-back" style="margin-top: 10px;">
					<view class="gameType-topTitle-view">
						<view class="gameType-topTitle">
							蜂计划入口 | PLAN BEE ENTRANCE
						</view>
						<view class="gameType-line"></view>
					</view>
					<view class="course-backview1" @click="createPlanTap">
						<image class="course-logo1" :src="courseData.dictUrl" mode="scaleToFill" />
						<view class="course-content1">
							<view class="plan-title1">{{courseData.dictLabel}}</view>
							<view class="plan-english1">{{courseData.dictName}}</view>
							<view class="course-tag1" v-if="courseData.tag">{{courseData.tag}}</view>
						</view>
					</view>
				</view>
				<view class="gameType-content-back">
					<view class="gameType-topTitle-view">
						<view class="gameType-topTitle">
							蜂计划备赛套餐 | Plan B Package
						</view>
						<view class="gameType-line"></view>
					</view>
					<block v-for="(item, index) in productList" :key="index">
						<lexIconHomeCell :courseData="item" rightStr="GO" :dataIndex="index" @wordClicked="wordClicked">
						</lexIconHomeCell>
					</block>
				</view>
			</view>
		</scroll-view>
		<popPromptBox v-if="showMessage" :msg="msg" @confirm="hidePromptbox"></popPromptBox>
	</view>
</template>

<script>
	import lexIconHomeCell from '../../components/lexIconCom/lexIconHomeCell.vue'
	export default {
		components: {
			lexIconHomeCell
		},
		data() {
			return {
				showMessage: false,
				msg: '',
				productList: [],
				scrollHeight: uni.getSystemInfoSync().windowHeight,
				courseData: {
					dictUrl: '',
					dictLabel: '点击创建蜂计划',
					dictUrl: 'https://cdn.spbcn.org/spbcnWechat/fengjihua_creat.png',
					dictName: 'Create Bee Plan',
					tag: '立即备赛'
				}
			}
		},
		onReady() {
			const that = this
			uni.createSelectorQuery().select('.top-menu').boundingClientRect(rect => {
				that.scrollHeight = uni.getSystemInfoSync().windowHeight - rect.bottom - 10;
			}).exec();
		},
		onLoad() {
			var formData = {};
			formData.activityType = this.$statusCode.activityType;;
			formData.subTypeCategory = 'reserve_package';
			this.getProductList(formData);
		},
		methods: {
			hidePromptbox() {
				this.showMessage = false;
			},
			wordClicked() {
				this.showMessage = true;
				this.msg = this.$statusCode.payPopMessage;
			},
			// 获取组别数据
			getProductList: function(formData) {
				this.$http.getAppletsProductList(formData).then(res => {
					if (res.code = 200) {
						var dataList = res.data.map(item => {
							item.tag = '备赛套餐';
							item.dictUrl = 'https://cdn.spbcn.org/spbcnappneed/lexicon_place.png';//item.imgUrl;
							item.dictName = item.productEngName;
							return item
						})
						console.log('dataList', dataList);
						this.productList = dataList;
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 2000
						})
					}
				})
			},
			//创建蜂计划
			createPlanTap: function() {
				this.$http.checkExpire({}).then(res => {
					if (res.code == 200) {
						if (res.data.isExpire == 1 || res.data.isExpire == 2) {
							this.showMessage = true;
							this.msg = this.$statusCode.payPopMessage;
						} else {
							uni.navigateTo({
								url: '/pages/planBee/createdPlanBee?days=' + res.data.days,
							})
						}
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 2000
						})
					}
				})
			}
		}
	}
</script>
<style lang="scss" scoped>
	.gameType-content-back {
		width: 94%;
		display: flex;
		position: relative;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		box-sizing: border-box;
		border-radius: 20px;
		background: white;
		padding: 5px 0px 15px 0px;
		margin-bottom: 20px;
		box-shadow: 3px 3px 10px 3px rgb(160, 160, 160);
	}

	.top-menu {
		width: 90%;
		margin-left: 5%;
		height: 5px;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-around;
	}

	.course-backview1 {
		width: 90%;
		height: 90px;
		padding: 0px 30px;
		border-top-left-radius: 45px;
		border-bottom-left-radius: 45px;
		border-top-right-radius: 10px;
		border-bottom-right-radius: 10px;
		border-end-end-radius: 10px;
		box-shadow: 0px 6px 0px 0px #908064;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: flex-start;
		margin-top: 18px;
		background: black;

		.course-logo1 {
			width: 75px;
			height: 75px;
		}

		.course-content1 {
			margin-left: 10px;
			height: 80px;
			flex: 1;
			display: flex;
			flex-direction: column;
			align-items: flex-start;
			justify-content: center;
		}

		.plan-title1 {
			width: 150px;
			color: white;
			font-size: 16px;
			font-family: 'hzgb';
		}

		.plan-english1 {
			width: 150px;
			font-size: 9px;
			color: white;
			font-family: 'hzgb';
		}

		.course-tag1 {
			height: 15px;
			border-radius: 8px;
			background-color: #e94851;
			text-align: center;
			margin-top: 5px;
			line-height: 15px;
			font-size: 8px;
			color: white;
			font-family: 'hzgb';
			padding: 0px 15px;
		}
	}
</style>